#include "service.hpp"

#define conf_path "./server.conf" 

int main()
{
    std::ifstream ifs;
    ifs.open(conf_path);
    if(!ifs.is_open())
    {
        perror("open fail\n");
        exit(-1);
    }
    ifs.seekg(0,ifs.end);
    int len=ifs.tellg();
    ifs.seekg(0,ifs.beg);

    char buffer[len];
    ifs.read(buffer,255);
    Json::Value root;
    JsonUtil::UnSerialize(root,buffer,len);

    //获取配置信息
    int port=root["server_port"].asInt();
    int buffer_size=root["buffer_size"].asInt();
    std::string log_path=root["log_path"].asCString();


    UDPServer server(port,buffer_size,log_path);
    if (!server.start())
    {
        return -1;
    }
    server.run();
    return 0;
}